<template>
  <div class="page">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
          <div class="layui-card">
            <div class="layui-card-body">
              <div class="layui-form" lay-filter style="font-size:15px;">

                  <div class="layui-form-item">
                  <label class="layui-form-label">代理商</label>
                  <div class="layui-input-inline">
                    <select name="level" lay-filter="level"  v-model="itemData.level">
                      <option  value="2" >大区长</option>
                      <option  value="3" >省总裁</option>
                      <option  value="4" >秘书长</option>
                    </select>
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">WDT配赠</label>
                  <div class="layui-input-inline" style="width: 190px;">
                    <input
                      type="number"
                      name='balanceZxzc'
                      placeholder="输入(专项资产)配赠"
                      v-model="itemData.balanceZxzc"
                      autocomplete="off"
                      class="layui-input"
                    />
                  </div>
                </div>          

                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button
                      class="layui-btn layui-btn-normal"
                      lay-submit
                      lay-filter="setmyinfo"
                      @click="sure"
                    >确认</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "proxyadd",
  data() {
    return {
      id: "",
      itemData: {
        level:"",//代理商
        balanceZxzc: "", //WDT(专项资产)配赠
      },

    };
  },
  mounted() {
    var _this = this;
    window.getdates = this.getdates;
  },
  methods: {
    getdates: function (data) {
      //回选详情
      var _this = this;
      var url = "/profit/aapi/v1.9/proxy-region-level/" + data.id;
      ajaxRequest(url, "GET", "json", "", function (ret, err) {
        //alert(JSON.stringify(ret))
        _this.itemData = ret.data;
        _this.id = ret.data.id;
        _this.itemData.balanceZxzc = ret.data.balanceZxzc / 100;

      });
    },
    sure: function () {
      var _this = this;
      var hat = "POST";
      var dates = _this.itemData;
      dates.balanceZxzc = _this.itemData.balanceZxzc * 100;
      if (_this.id) {
        dates.id = _this.id;
        hat = "PUT";
      }
      var url = "/profit/aapi/v1.9/proxy-region-level";
      // alert(JSON.stringify(dates))
      ajaxRequest(url, hat, "json", dates, function (ret, err) {
        layer.msg("操作成功");
        setTimeout(function () {
          var index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
            parent.location.reload();
        }, 1000);
      });
    },
  },
  updated: function () {
    var _this = this;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
      form.render('select','level');
      form.on("select(level)", function (data) {
        _this.itemData.level = data.value;
      });
    });
  },
};
</script>
<style>
</style>